<div id="placeholder_{{object.id}}">

<p><a href="http://get.adobe.com/flashplayer">Get Flash</a> to see this player.</p>
</div>
<div class="controls">
<a href="javascript:player_{{ object.id }}.sendEvent('PLAY')">Play/Pause</a>
<a href="javascript:player_{{ object.id }}.sendEvent('SEEK', currentPosition-10);">&lt;&lt;</a>
<a href="javascript:player_{{ object.id }}.sendEvent('SEEK', currentPosition+10);">&gt;&gt;</a>

<span id="player_time">
</span>

</div>

<script type="text/javascript" src="{{ MEDIA_URL }}js/swfobject.js"></script>
<script type="text/javascript">
/* <![CDATA[ */

    function createPlayer() {
        var flashvars = {
                file:"{{ MEDIA_URL }}{{ object.video }}", 
                autostart:"false",
                controlbar:"none",
                //enablejs: true,
                //searchbar:false,
                //hownavigation: false,
        }
        var params = {
                allowfullscreen:"true", 
                allowscriptaccess:"always"
        }
        var attributes = {
                    id:"player_{{object.id}}",
                    name:"player_{{object.id}}"
            }
        swfobject.embedSWF("{{ MEDIA_URL }}swf/player-viral.swf", "placeholder_{{ object.id}}", "320", "196", "9.0.115", false, flashvars, params, attributes);
    }

    createPlayer();    

    var player_{{ object.id }} = null; 
    /* swf does a callback */
    function playerReady(thePlayer) { 
        player_{{ object.id }}  = document.getElementById("player_{{object.id}}"); 
        addListeners();
    }

    /* 
http://home5.inet.tele.dk/nyboe/flash/mediaplayer4/JW_API_xmpl_6-2-0-0.html
    */
    function addListeners() {
        if (player_{{ object.id }}) { 
            //player.addControllerListener("ITEM", "itemListener");
            //player.addControllerListener("MUTE", "muteListener");

            //player.addModelListener("LOADED", "loadedListener");
            //player.addModelListener("STATE", "stateListener");
            player_{{ object.id }}.addModelListener("TIME", "positionListener");

            //player.addViewListener("VOLUME", "volumeListener");
        } else {
            setTimeout("addListeners()",100);
        }
    }

    function positionListener(obj) { 
        currentPosition = obj.position; 
        var tmp = document.getElementById("player_time");
        if (tmp) { tmp.innerHTML = "position: " + currentPosition; }
    }

/* ]]> */
</script>


